import { isUserVip } from '@/api/bks.consult.js'
import { bksFunctionInfo } from '@/api/bks.index.js'
// 获取备考生信息
export const getBksInfo = (type) =>{
	// type: token , isVip, user
	const bw_bks_params = uni.getStorageSync('bw_bks_params') || {}
	const bw_bks_user = uni.getStorageSync('bw_bks_user') || {}
	if(type == 'token'){
		return new Promise(function (resolve, reject) {
			if(bw_bks_params && bw_bks_params.access_token){
				resolve(bw_bks_params)
			}else{
				reject('')
			}
		})
	}else if(type == 'user'){
		return new Promise(function (resolve, reject) {
			if(bw_bks_params && bw_bks_params.access_token){
				resolve({bw_bks_params, bw_bks_user})
			}else{
				reject('')
			}
		})
	}else if(type == 'isVip'){
		return new Promise(function (resolve, reject) {
			if(bw_bks_params && bw_bks_params.access_token){
			  isUserVip().then(res=>{
				  resolve({ isVip: res.data, bw_bks_user, bw_bks_params})
			  }).catch(err=>{
				  resolve({ isVip: false, bw_bks_user, bw_bks_params})
			  })
			}else{
				reject('')
			}
		})
	}
	
}
// 获取VIP状态,返回vip状态,本地用户信息
// export getIsVip(callback) {
// 	const bw_bks_params = uni.getStorageSync('bw_bks_params') || ''
// 	if (bw_bks_params && bw_bks_params.access_token) {
// 		const bw_bks_user = uni.getStorageSync('bw_bks_user') || {}
// 		// isUserVip().then(res => {
// 		// 	callback({
// 		// 		isVip: res.data,
// 		// 		user: bw_bks_user
// 		// 	})
// 		// }).catch(err => {
// 		// 	callback({
// 		// 		isVip: false,
// 		// 		user: bw_bks_user
// 		// 	})
// 		// })
// 		return new Promise(function (resolve, reject) {
// 		  isUserVip(data).then(res=>{
// 			  resolve({ isVip: res.data, user: bw_bks_user})
// 		  }).catch(err=>{
// 			  resolve({ isVip: false, user: bw_bks_user})
// 		  })
// 		})
// 	} else {
// 		this.$pageTo('/bks/login/index/index')
// 	}
// }

// 获取后台配置图片
export const getActionInfo = (data) => {
  return new Promise(function (resolve, reject) {
    bksFunctionInfo(data).then(res=>{
		resolve(res)
    }).catch(err=>{
		resolve(err)
    })
  })
}